<?php
namespace app\service\user;

use app\model\User as UserModel;

class UserService implements IUserService {

    //region 方法

    /**
     * 获取用户列表
     * @param $queryCode
     * @param $pageSize
     * @return mixed|\think\Paginator
     * @throws \think\exception\DbException
     */
    public function getUserList($queryCode, $pageSize)
    {
        $userModel = new UserModel();
        $page_param = ['query' => []];
        if(!empty($queryCode)) {
            $page_param['query']['queryCode'] = $queryCode;
            $keyWord = '%' . $queryCode . '%';
            $userModel->where('user_name', 'like', $keyWord)
            ->whereOr('user_account', 'like', $keyWord);
        }
        $list = $userModel->alias('user')->join('aya_role role', 'user.user_role_id = role.role_id')
            ->where('user.user_status', '<>', -1)
            ->paginate($pageSize, false, $page_param);
        return $list;
    }

    //endregion
}